home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / misc / e-n / ifx21to21a / patches.lha / Rexx / CreateNails.ifx
Text File  |  1995-07-25  |  3KB  |  145 lines

  1. /*
  2.  * $VER: CreateNails 2.2 (25.7.95)
  3.  *
  4.  * Arexx program for the ImageFX image processing system.
  5.  * Written by Thomas Krehbiel
  6.  *
  7.  * Copyright © 1992-1995 Nova Design, Inc.
  8.  * All Rights Reserved
  9.  *
  10.  * CreateNails - Generate thumbnail files for existing images.
  11.  *
  12.  *    17.01.95 tek   Added support for linked thumbnails.
  13.  *    06.06.95 tek   Fixed problem handling paths with trailing ":".
  14.  *
  15.  */
  16.  
  17. OPTIONS RESULTS
  18.  
  19. SIGNAL ON BREAK_C
  20.  
  21. loadopt = 'NOALPHA SMOOTH'
  22.  
  23.  
  24. lpath = GETCLIP('CREATENAILS_Path')
  25. pattern = GETCLIP('CREATENAILS_Pat')
  26. bits = GETCLIP('CREATENAILS_Bits')
  27.  
  28. IF lpath = "" THEN DO
  29.    GetPrefs LoadPath
  30.    lpath = result
  31.    END
  32. IF bits = "" THEN bits = 24
  33. IF pattern = "" THEN pattern = '#?'
  34.  
  35.  
  36. RequestFile '"Select Directory To Convert:"' '"'lpath'"' '" "' '"'pattern'"'
  37. IF rc ~= 0 THEN EXIT
  38.  
  39. lpath = filereq.path
  40. pattern = filereq.pat
  41.  
  42. IF (RIGHT(lpath,1) ~= ':' & RIGHT(lpath,1) ~= '/') THEN lpath = lpath || '/'
  43.  
  44. IF pattern = "" THEN pattern = '#?'
  45.  
  46. RequestThree '"Select Thumbnail Color Depth:"' '"24-Bit"' '"12-Bit"' '"Cancel"'
  47. IF rc ~= 0 THEN EXIT
  48.  
  49. IF result = '24-Bit' THEN bits = 24
  50. IF result = '12-Bit' THEN bits = 12
  51.  
  52. RequestThree '"Do you want to store the thumbnails in another directory?"' '"Yes"' '"No"' '"Cancel"'
  53. IF rc ~= 0 THEN EXIT
  54.  
  55. tpath = ""
  56.  
  57. IF result = 'Yes' THEN DO
  58.  
  59.    tpath = GETCLIP('CREATENAILS_TPath')
  60.  
  61.    RequestFile '"Select Directory For Thumbnails:"' '"'tpath'"' DIRONLY
  62.    IF rc ~= 0 THEN EXIT
  63.  
  64.    tpath = filereq.path
  65.  
  66.    CALL SETCLIP('CREATENAILS_TPath', tpath)
  67.  
  68.    IF tpath = lpath THEN tpath = ""
  69.  
  70.    END
  71.  
  72. CALL SETCLIP('CREATENAILS_Path', lpath)
  73. CALL SETCLIP('CREATENAILS_Pat', pattern)
  74. CALL SETCLIP('CREATENAILS_Bits', bits)
  75.  
  76. opts = bits
  77. IF tpath ~= "" THEN opts = opts || ' "'tpath'"'
  78.  
  79. /* list all files matching the pattern */
  80. ADDRESS COMMAND 'List >RAM:__NAILS_TEMP__ NOHEAD LFORMAT="'lpath'%s" PAT="'pattern'" "'lpath'"'
  81. IF rc ~= 0 THEN DO
  82.    RequestNotify 'Error creating list of files.  Error Code' rc'.'
  83.    EXIT
  84.    END
  85.  
  86. /* sort alphabetically */
  87. ADDRESS COMMAND 'Sort RAM:__NAILS_TEMP__ TO RAM:__NAILS_LIST__'
  88. ADDRESS COMMAND 'Delete RAM:__NAILS_TEMP__ QUIET'
  89.  
  90. IF ~OPEN(infile, 'RAM:__NAILS_LIST__', 'Read') THEN DO
  91.    RequestNotify 'Cannot open file list.'
  92.    EXIT
  93.    END
  94.  
  95. Undo Off
  96.  
  97. LockInput
  98.  
  99.  
  100. /* go through the list one by one */
  101. DO WHILE ~EOF(infile)
  102.  
  103.    nextfile = READLN(infile)
  104.  
  105.    IF nextfile ~= "" THEN DO
  106.  
  107.       IF RIGHT(nextfile,5)='.info' THEN ITERATE
  108.       IF RIGHT(nextfile,5)='.nail' THEN ITERATE
  109.  
  110.       Message nextfile
  111.  
  112.       LoadBuffer '"'nextfile'"' FORCE loadopt
  113.       IF rc ~= 0 THEN DO
  114.          Message 'LOAD FAILED!'
  115.          ITERATE  /* skip to next one anyway */
  116.          END
  117.  
  118.       CreateNailFile '"'nextfile'"' opts
  119.  
  120.       END
  121.  
  122.    END
  123.  
  124. CALL CLOSE(infile)
  125.  
  126.  
  127. ADDRESS COMMAND 'Delete RAM:__NAILS_LIST__ QUIET'
  128.  
  129. KillBuffer Force
  130. UnlockInput
  131. Undo On
  132.  
  133. EXIT
  134.  
  135.  
  136. /* if script is terminated: */
  137. BREAK_C:
  138.  
  139.    ADDRESS COMMAND 'c:Delete RAM:__NAILS_LIST__ QUIET'
  140.    KillBuffer Force
  141.    UnlockInput
  142.    Undo On
  143.  
  144.    EXIT
  145.